package com.newenergy.wisehome.data.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import java.util.UUID;

/**
 * Created by dell on 2017/3/24.
 * 球泡灯实体类
 */

@DatabaseTable(tableName = "tb_balllight")
public class BallLight implements Parcelable {

    @DatabaseField(generatedId = true)
    private int id;
    @DatabaseField(columnName = "uuid")
    private String uuid= UUID.randomUUID().toString();
    @DatabaseField(columnName = "familyId")
    private String familyId;
    @DatabaseField(columnName = "category")
    private int category = 1;//1代表球泡灯种类
    @DatabaseField(columnName = "groupId")
    private String groupId;
    @DatabaseField(columnName = "name")
    private String name;
    @DatabaseField(columnName = "pingyinName")
    private String pingyinName;
    @DatabaseField(columnName = "isChecked")
    private boolean isChecked = false;
    @DatabaseField(columnName = "icName")
    private String icName = "icon_bedroom";
    @DatabaseField(columnName = "ld1")
    private int ld1 = 116;
    @DatabaseField(columnName = "ld2")
    private int ld2 = 116;
    @DatabaseField(columnName = "sw")
    private int sw = 127;
    @DatabaseField(columnName = "rgb")
    public String rgb="FF0000";
    @DatabaseField(columnName = "mode")//2代表黄白，1代表RGB
    private int mode = 2;
    @DatabaseField(columnName = "centerX")
    private int centerX = 133;
    @DatabaseField(columnName = "centerY")
    private int centerY = 133;
    @DatabaseField(columnName = "scenedata")
    private String scenedata;

    @DatabaseField(columnName = "endTime")
    private long endTime;
    @DatabaseField(columnName = "timeDesc")//时间描述
    private String timeDesc;


/*    @DatabaseField(columnName = "deviceId")//设备id
    private String deviceId="00000000";*/


    public BallLight() {
    }

    public BallLight(String familyId, int category, String name) {
        this.familyId = familyId;
        this.category = category;
        this.name = name;
    }

    public BallLight(String familyId, int category, String groupId, String name) {
        this.familyId = familyId;
        this.category = category;
        this.groupId = groupId;
        this.name = name;
    }

    public BallLight(String familyId, int category, String groupId, String name, String icName) {
        this.familyId = familyId;
        this.category = category;
        this.groupId = groupId;
        this.name = name;
        this.icName = icName;
    }

    public BallLight(String familyId, int category, String groupId, String name, String pingyinName, String icName, String scenedata) {
        this.familyId = familyId;
        this.category = category;
        this.groupId = groupId;
        this.name = name;
        this.pingyinName=pingyinName;
        this.icName = icName;
        this.scenedata=scenedata;
    }


    public BallLight(String familyId, int category, String groupId, String name, String pingyinName, String icName) {
        this.familyId = familyId;
        this.category = category;
        this.groupId = groupId;
        this.name = name;
        this.pingyinName=pingyinName;
        this.icName = icName;
    }


    public BallLight(int category, String groupId, String name, String icName) {
        this.category = category;
        this.groupId = groupId;
        this.name = name;
        this.icName = icName;
    }

    public int getId() {
        return id;
    }

    public String getUuid() {
        return uuid;
    }

    public int getCategory() {
        return category;
    }

    public void setCategory(int category) {
        this.category = category;
    }


    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPingyinName() {
        return pingyinName;
    }

    public void setPingyinName(String pingyinName) {
        this.pingyinName = pingyinName;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }


    public String getIcName() {
        return icName;
    }

    public void setIcName(String icName) {
        this.icName = icName;
    }

    public String getFamilyId() {
        return familyId;
    }

    public void setFamilyId(String familyId) {
        this.familyId = familyId;
    }

    public int getLd1() {
        return ld1;
    }

    public void setLd1(int ld1) {
        this.ld1 = ld1;
    }

    public int getLd2() {
        return ld2;
    }

    public void setLd2(int ld2) {
        this.ld2 = ld2;
    }

    public int getSw() {
        return sw;
    }

    public void setSw(int sw) {
        this.sw = sw;
    }

    public String getRgb() {
        return rgb;
    }

    public void setRgb(String rgb) {
        this.rgb = rgb;
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public int getCenterX() {
        return centerX;
    }

    public void setCenterX(int centerX) {
        this.centerX = centerX;
    }

    public int getCenterY() {
        return centerY;
    }

    public void setCenterY(int centerY) {
        this.centerY = centerY;
    }

    public String getScenedata() {
        return scenedata;
    }

    public void setScenedata(String scenedata) {
        this.scenedata = scenedata;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

    public String getTimeDesc() {
        return timeDesc;
    }

    public void setTimeDesc(String timeDesc) {
        this.timeDesc = timeDesc;
    }

   /* public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }*/

    @Override
    public String toString() {
        return "BallLight{" +
                "id=" + id +
                ", familyId='" + familyId + '\'' +
                ", category=" + category +
                ", groupId='" + groupId + '\'' +
                ", name='" + name + '\'' +
                ", pingyinName='" + pingyinName + '\'' +
                ", isChecked=" + isChecked +
                ", icName='" + icName + '\'' +
                ", ld1=" + ld1 +
                ", ld2=" + ld2 +
                ", sw=" + sw +
                ", rgb='" + rgb + '\'' +
                ", mode=" + mode +
                ", centerX=" + centerX +
                ", centerY=" + centerY +
                ", scenedata='" + scenedata + '\'' +
                '}';
    }


    public DeviceCategory  covertToDeviceCategory(){
        DeviceCategory deviceCategory=new DeviceCategory(uuid,familyId,category,groupId,name,pingyinName,icName);
        return deviceCategory;
    }

    public String toQRContent() {
        return groupId + "&" + name+ "&" + category;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.id);
        dest.writeString(this.uuid);
        dest.writeString(this.familyId);
        dest.writeInt(this.category);
        dest.writeString(this.groupId);
        dest.writeString(this.name);
        dest.writeString(this.pingyinName);
        dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
        dest.writeString(this.icName);
        dest.writeInt(this.ld1);
        dest.writeInt(this.ld2);
        dest.writeInt(this.sw);
        dest.writeString(this.rgb);
        dest.writeInt(this.mode);
        dest.writeInt(this.centerX);
        dest.writeInt(this.centerY);
        dest.writeString(this.scenedata);
        dest.writeLong(this.endTime);
        dest.writeString(this.timeDesc);
//        dest.writeString(this.deviceId);
    }

    protected BallLight(Parcel in) {
        this.id = in.readInt();
        this.uuid = in.readString();
        this.familyId = in.readString();
        this.category = in.readInt();
        this.groupId = in.readString();
        this.name = in.readString();
        this.pingyinName = in.readString();
        this.isChecked = in.readByte() != 0;
        this.icName = in.readString();
        this.ld1 = in.readInt();
        this.ld2 = in.readInt();
        this.sw = in.readInt();
        this.rgb = in.readString();
        this.mode = in.readInt();
        this.centerX = in.readInt();
        this.centerY = in.readInt();
        this.scenedata = in.readString();
        this.endTime = in.readLong();
        this.timeDesc = in.readString();
//        this.deviceId = in.readString();
    }

    public static final Parcelable.Creator<BallLight> CREATOR = new Parcelable.Creator<BallLight>() {
        @Override
        public BallLight createFromParcel(Parcel source) {
            return new BallLight(source);
        }

        @Override
        public BallLight[] newArray(int size) {
            return new BallLight[size];
        }
    };
}
